﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Partial Class Control_sysFunction_sysFunctionMenu
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            BindMenu()
        End If
    End Sub
    Protected Sub BindMenu()
        Using data As New VSEntities
            If Session("Function") Is Nothing Then
                Response.Redirect("~/Login.aspx")
            End If
            'Dim arrFuntionId As Integer() = Session("Function")
         

            Dim p = From q In data.SysFunctions Where q.IsMenu = True Order By q.FunctionName Ascending Select q
            'check role here
            With rptMenu
                .DataSource = p
                .DataBind()
            End With
        End Using
    End Sub

    Protected Sub rptMenu_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMenu.ItemDataBound
        Dim hplTitle As HyperLink
        hplTitle = e.Item.FindControl("hplTitle")
        Dim sufixURL = Request.Url.ToString.Split("Page")(0)
        Dim data As New SysFunction
        Dim p = CType(e.Item.DataItem, SysFunction)
        hplTitle.NavigateUrl = MainDomain & p.URL
        If Request.Url.ToString.Contains(p.URL.Replace("List.aspx", "")) Then
            hplTitle.Text = "<span class=""current"">" & p.FunctionName & "</span>"
            hplTitle.CssClass = "current"
        Else
            hplTitle.Text = "<span>" & p.FunctionName & "</span>"
        End If

    End Sub
End Class
